package com.fjec.market.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fjec.common.protocol.JsonResult;
import com.fjec.common.view.ListItem;
import com.fjec.market.entity.InfoBank;
import com.fjec.market.entity.InfoBankType;
import com.fjec.market.mapper.InfoBankTypeMapper;
import com.fjec.market.service.IInfoBankTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author admin
 * @since 2020-10-30
 */
@Service
public class InfoBankTypeServiceImpl extends ServiceImpl<InfoBankTypeMapper, InfoBankType> implements IInfoBankTypeService {

    @Resource
    private InfoBankTypeMapper mapper;

    @Override
    public JsonResult getAllInfoBankType() {
        QueryWrapper<InfoBankType> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("DelFlag", 0)
                .orderByAsc("Sort");
        List<ListItem> resultList = new ArrayList<>();
        List<InfoBankType> entityList = mapper.selectList(queryWrapper);
        for (InfoBankType entity : entityList) {
            resultList.add(new ListItem(entity.getBankType(),
                    entity.getBankName()));
        }
        return JsonResult.success()
                .data(resultList)
                .build();
    }
}
